<?php

class Companies_model extends CI_Model{
    private  $_table='companies';


    public function get_companies($counter=FALSE){
     if(!$counter){
        $query=$this->db->get($this->_table,PAGR_PER,0);
        return $query->result_array();
     }
     else{
        $query=$this->db->get($this->_table);
        return $query->num_rows();
     }
         
}
public function get_companies_where($params=array()){
    $where='( 1 )';
    if(!empty($params['id']))
        $where.=' AND (id='.$params['id'].')';
    $query=$this->db->get_where($this->_table,$where);
    return $query->row_array();
}

 public function insert_companies($params=array()){
        return $query=$this->db->insert($this->_table,$params);
    }
public function update_companies($params = array(),$id) {
        if(isset($id)){
            $where='id='.$id;
            return $this->db->update_string($this->_table,$params,$where);
        }
        else{
            return FALSE;
        }
    }
  public function delete_companies($id) {
        if(isset($id)){
            return $this->db->delete($this->_table,array('id'=>$id));
        }
        else{
            return FALSE;
        }
    }


}

